import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

const state = {
  token: ''
}

const mutations = {
  changeToken (state, token) {
    state.token = token
  }
}

const store = new Vuex.Store({
  plugins: [
    createPersistedState({
      reducer (val) {
        return {
          // 只持久化储存state中的mohou_token等
          token: val.token
        }
      }
    })
  ],
  state: state,
  mutations: mutations
})

export default store
